package com.zs.toolbox.web2j.auth.security;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * @author shuai.zhang  on 2018/9/13
 * @version 1.0.0
 * @description
 * @deprecated 直接在controller层做通过JWT做登陆处理
 */
@Component
@Slf4j
public class WtUserAuthServiceImpl implements UserDetailsService {

    @Autowired
    BCryptPasswordEncoder bCryptPasswordEncoder;

    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        return new User("zs", bCryptPasswordEncoder.encode("123456")
                , Arrays.asList(new SimpleGrantedAuthority("ROLE_ADMIN")));
    }
}
